/*
 * Cursor.cpp
 *
 *  Created on: Aug 20, 2010
 *      Author: Ry
 */

#include <gl/glew.h>
#include "Cursor.h"

Cursor::Cursor(int id, ShaderProgram *shaderProgram) : GLComponent(shaderProgram) {
	this->id = id;
	backgroundColor = RGBA(1.0f, 0.0f, 0.0f, 1.0f);
}

void Cursor::draw() {
	shaderProgram->use();
	GLint locColor = glGetAttribLocation(shaderProgram->getHandle(), "color");
	glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	glBegin(GL_LINES);
	glVertexAttrib4fv(locColor, backgroundColor.getValue());

	int centerX = rect.centerX();
	int centerY = rect.centerY();

	glVertex2i(centerX, centerY + 5);
	glVertex2i(centerX, centerY - 5);

	glVertex2i(centerX + 5, centerY);
	glVertex2i(centerX - 5, centerY);

	glEnd();
}

void Cursor::handleEvent(GUIEvent *event) {
	// Just ignore gui events.
}

Cursor::~Cursor() {
}
